﻿using System;
using System.Web;

namespace FlickrXplorer.Web
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            GotoMostInteresting();
        }

        // get interesting photos returns crap if not filtered, so going for new method.
        private string most_popular = System.Configuration.ConfigurationManager.AppSettings["popular_words"];

        public void GotoMostInteresting()
        {
            string[] parts = most_popular.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            int pIndex = new Random().Next(0, parts.Length - 1);

            bool integrated = (bool)HttpContext.Current.Items["IntegratedMode"];

            if (integrated)
            {
                Response.Redirect("~/Photo/" + parts[pIndex]);
            }
            else
            {
                Response.Redirect("~/Photo.mvc/" + parts[pIndex]);
            }
        }
    }
}
